package com.baizhi.service.imp;

import com.baizhi.service.ArticleService;
import com.baizhi.dao.ArticleDao;
import com.baizhi.entity.Article;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImp implements ArticleService {

    @Resource
    private ArticleDao articleDao;

    @Override
    public PageInfo<Article> findAll(Integer page, Integer limit, Article article) {
        PageHelper.startPage(page, limit);
        List<Article> articleList=articleDao.selectAll(article);
        return new PageInfo<>(articleList);
    }

    @Override
    public Article fidnArticlByFields(Article article) {
        return articleDao.selectArticlByFields(article);
    }

    @Override
    public void addArticle(Article article) {
        articleDao.insertArticle(article);
    }

    @Override
    public void removeArticleById(Integer id) {
        articleDao.deleteArticleById(id);
    }

    @Override
    public void removeMultiple(Integer[] ids) {
        articleDao.deleteMultiple(ids);
    }

    @Override
    public void renovateArticle(Article article) {
        articleDao.updateArticle(article);
    }

}
